#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#include <immintrin.h>
//#include <emmintrin.h>
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define fi first
#define se second
#define pii pair<int,int>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=998244353;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,k;
int a[N],id[N];
int gg[N],tot;
int tr[N];
inline int lowbit(int x){return x&(-x);}
inline void add(int x,int k){
	while(x){
		tr[x]=max(tr[x],k);x-=lowbit(x);
	}
}inline int qry(int x){
	int res=-1e9;
	while(x<=tot){
		res=max(res,tr[x]);x+=lowbit(x);
	}return res;
}
int f[N];
inline bool check(int x){
	For(i,0,tot) tr[i]=0;
	int ans=0;
	if(n<=1000){
		int l=1,r=tot,res=0;
		while(l<=r){
			int mid=(l+r)>>1;
			For(i,0,tot) tr[i]=-1e9;
			int ans=0;
			For(i,1,n){
				int res=qry(id[i])+1;
				if(a[i]<=gg[mid])res=max(res,1);
				add(upper_bound(gg+1,gg+tot+1,x-a[i])-gg-1,res);
				if(a[i]<=x-gg[mid]&&res>=k) return 1;
				ans=max(ans,res); 
			}
			if(ans<k) l=mid+1;
			else r=mid-1;
		}
		return 0; 
	}
	For(i,1,n){
		f[i]=qry(id[i])+1;
		add(upper_bound(gg+1,gg+tot+1,x-a[i])-gg-1,f[i]);
	}
	For(i,0,tot) tr[i]=-1e9;
	For(i,1,n)if(f[i]>=k)add(upper_bound(gg+1,gg+tot+1,x-a[i])-gg-1,1);
	For(i,1,n){
		int res=qry(id[i])+1;
		add(upper_bound(gg+1,gg+tot+1,x-a[i])-gg-1,res);
		if(res>=k+1) return 1;
	}return 0;
}
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read(),k=read();
	gg[++tot]=-2e9;
	For(i,1,n) gg[++tot]=a[i]=read();
	sort(gg+1,gg+tot+1);
	tot=unique(gg+1,gg+tot+1)-gg-1;
	For(i,1,n) id[i]=lower_bound(gg+1,gg+tot+1,a[i])-gg;
	int L=0,R=2e9,res=0;
	while(L<=R){
		int mid=L+(R-L>>1);
		if(check(mid))R=mid-1,res=mid;
		else L=mid+1;
	}printf("%d\n",res);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

